function Characters(opts) {
  this.x = opts.x;
  this.y = opts.y;
  this.frame = opts.frame;
  this.key = opts.key || 0;

}

Characters.prototype.init = function() {
  this.sprite = game.add.sprite(this.x, this.y, this.frame, this.key);
  game.physics.enable(this.sprite, Phaser.Physics.ARCADE);
  this.sprite.body.immovable = false;
  this.sprite.body.collideWorldBounds = true;
  this.sprite.body.bounce.setTo(1, 1);
  return this.sprite
};

Characters.prototype.stand = function() {
  this.sprite.animations.play('stand');
};

Characters.prototype.walkRight = function() {

  this.sprite.animations.play('run');
};

Characters.prototype.walkLeft = function() {

  this.sprite.animations.play('run');
};

function Hero () {

}

Hero.prototype.init = function() {
  this.hero = new Characters({
    x: 300,
    y: game.world.height - 300,
    frame: 'hero',
    key: 'Hero1.png'
  });

  this.sprite = this.hero.init();
  this.initAnimation(this.sprite);
  this.hero.stand();
};

Hero.prototype.initAnimation = function(sprite) {
  sprite.animations.add('stand', ['Hero1.png', 'Hero2.png', 'Hero3.png'], 5.8, true);

  sprite.animations.add('run', ['HeroRun1.png', 'HeroRun2.png', 'HeroRun3.png', 'HeroRun4.png', 'HeroRun5.png','HeroRun6.png','HeroRun7.png','HeroRun8.png','HeroRun9.png','HeroRun10.png','HeroRun11.png', 'HeroRun1.png'], 10, true);
  sprite.animations.add('attack', ['HeroAttack1.png', 'HeroAttack2.png', 'HeroAttack3.png', 'HeroAttack4.png', 'HeroAttack5.png'], 5.8, true);
  sprite.animations.add('jumpAttack', ['HeroAttackJ1.png', 'HeroAttackJ2.png', 'HeroAttackJ3.png', 'HeroAttackJ4.png', 'HeroAttackJ5.png', 'HeroAttackJ6.png', 'HeroAttackJ7.png','HeroAttackJ8.png'], 5.8, true);
  sprite.animations.add('tAttack', ['HeroAttackJ1.png', 'HeroAttackJ2.png', 'HeroAttackJ3.png'], 5.8, true);
  sprite.animations.play('stand');
};

Hero.prototype.moveRight = function() {
  this.sprite.body.velocity.x = 200;
  this.hero.walkRight()
};

Hero.prototype.moveLeft = function() {
  this.sprite.body.velocity.x = -200;
  this.hero.walkLeft()
};

Hero.prototype.stand = function() {
  this.sprite.body.velocity.setTo(0, 0);
  this.hero.stand();
}

